#define _GNU_SOURCE
#include "app_pool.h"
#include "log/log.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int task_fun(void *arg)
{
    char *data = (char *)arg;
    log_debug("task_fun arg=%s, tid=%d", data, gettid());
    free(data);
}

int main(int argc, char const *argv[])
{

    app_pool_init(5);

    for (int i = 0; i < 10; i++)
    {
        char *name = malloc(10);
        sprintf(name, "%s_%d", "atguigu", i);
        app_pool_registerTask(task_fun, name);
        // free(name); 不能释放，取到消息任务后就得不到name值了
    }
    
    sleep(1);
    log_debug("main exit");
    app_pool_close();
    
    return 0;
}
